<?php
namespace BP\DA;
use Exception;
class AtPara {
	protected $_HisHT;	// Hashtable
	private function __init() { // default class members
		$this->_HisHT = NULL;
	}
	public function getFK_Work () 
	{
		return $this->GetValStrByKey("FK_Work");
	}
	public function getFK_ZJ () 
	{
		return $this->GetValStrByKey("FK_ZJ");
	}
	public function getOID () 
	{
			/* match: String */
		return $this->GetValIntByKey_String("OID");
	}
	public function getDoType () 
	{
		return $this->GetValStrByKey("DoType");
	}
	public static function constructor__ () 
	{
		$me = new self();
		$me->__init();
		return $me;
	}
	public static function constructor__String ($para) // [String para]
	{
		$me = new self();
		$me->__init();
		if (($para . NULL))
		{
			return ;
		}
// 		$strs = $para->split("[@]", -1);
		$strs = explode('@', $para, -1);
		foreach ($strs as $str) 		{
			if ((($str == NULL) || $str->equals("")))
			{
				continue;
			}
// 			$mystr = $str->split("[=]", -1);
			$mystr = explode('=', $str, -1);
			if ((count($mystr) /*from: mystr.length*/ == 2))
			{
				$me->SetVal($mystr[0], $mystr[1]);
			}
			else
			{
				$v = "";
				for ($i = 1; ($i < count($mystr) /*from: mystr.length*/); ++$i) 
				{
					if (($i == 1))
					{
						$v += $mystr[$i];
					}
					else
					{
						$v += ("=" . $mystr[$i]);
					}
				}
				$me->SetVal($mystr[0], $v);
			}
		}
		return $me;
	}
	public function SetVal ($key, $val) // [String key, String val]
	{
		try 
		{
			$this->getHisHT()->put($key, $val);
		}
		catch (\Exception $e)
		{
			$this->getHisHT()->put($key, $val);
		}
	}
	public function GetValStrByKey ($key) // [String key]
	{
		$tempVar = $this->getHisHT()->get($key);
		$str = ( ($tempVar instanceof String) ? $tempVar : NULL );
		if (($str . NULL))
		{
			return "";
		}
		return $str;
	}
	public function GetValBoolenByKey_String ($key) // [String key]
	{
			/* match: String */
		if (($this->GetValIntByKey_String($key) == 0))
		{
			return  FALSE ;
		}
		return  TRUE ;
	}
	public function GetValBoolenByKey_String_b ($key, $isNullAsVal) // [String key, boolean isNullAsVal]
	{
		$str = $this->GetValStrByKey($key);
		if ((DataType::IsNullOrEmpty($str) ==  TRUE ))
		{
			return $isNullAsVal;
		}
		if (($str->equals("0") ==  TRUE ))
		{
			return  FALSE ;
		}
		return  TRUE ;
	}
	public function GetValFloatByKey_String ($key) // [String key]
	{
			/* match: String_F */
		return $this->GetValFloatByKey_String_F($key, 0);
	}
	public function GetValFloatByKey_String_F ($key, $isNullAsVal) // [String key, float isNullAsVal]
	{
		try 
		{
			return $Float->parseFloat($this->GetValStrByKey($key));
		}
		catch (\Exception $e)
		{
			return $isNullAsVal;
		}
	}
	public function GetValIntByKey_String ($key) // [String key]
	{
			/* match: String_I */
		return $this->GetValIntByKey_String_I($key, 0);
	}
	public function GetValIntByKey_String_I ($key, $isNullAsVal) // [String key, int isNullAsVal]
	{
		$str = $this->GetValStrByKey($key);
		if (($str->equals("undefined") || DataType::IsNullOrEmpty($str)))
		{
			return $isNullAsVal;
		}
		return $Integer->parseInt($str);
	}
	public function GetValInt64ByKey ($key) // [String key]
	{
		try 
		{
			return $Long->parseLong($this->GetValStrByKey($key));
		}
		catch (\Exception $e)
		{
			return 0;
		}
	}
	public function getHisHT () 
	{
		if (($this->_HisHT == NULL))
		{
			$this->_HisHT = [];// map
		}
		return $this->_HisHT;
	}
	public function GenerAtParaStrs () 
	{
		$s = "";
		foreach ($this->getHisHT()->keySet() as $key) 		{
			$s += ((("@" . $key) . "=") . $this->_HisHT->get($key));
		}
		return $s;
	}
}
?>
